<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>项目管理</title>
    <link type="text/css" rel="stylesheet" href="/static/bt/bootstrap-3.3.5/css/bootstrap.min.css">
    <link type="text/css"  href="/static/bt/layer/skin/layer.css">
    <link rel="stylesheet" type="text/css" href="/static/bt/bootstraptable/themes/bootstrap-table/bootstrap-table.css">
    <script type="text/javascript" src="/static/bt/js/jquery-1.10.2.min.js"></script>
    <script type="text/javascript" src="/static/bt/bootstrap-3.3.5/js/bootstrap.js"></script>
    <script type="text/javascript" src="/static/bt/layer/layer.js"></script>
    <script type="text/javascript" src="/static/bt/bootstraptable/themes/bootstrap-table/bootstrap-table.js"></script>
    <script type="text/javascript" src="/static/bt/bootstraptable/locale/bootstrap-table-zh-CN.js"></script>

    <script type="text/javascript">
        $(function(){
            $('#dataTable').bootstrapTable({
                columns: [{
                    field: 'id',
                    title: '项目Id',
                    align:'center'
                },{
                    field: 'name',
                    title: '项目名称',
                    align:'center'
                },{
                    field: 'createTime',
                    title: '创建时间',
                    align:'center',
                    sortable:true
                },{
                    title: "操作",
                    align:'center',
                    width:"300",
                    formatter:function(value,row,index)
                    {

                        var buttonText=
                            "<button class='btn btn-warning' type='button' onclick='openFileMember(\""+row.id+"\")'><i class='glyphicon glyphicon-folder-open'></i>&nbsp;文件管理器</button>&nbsp;&nbsp;"+
                            "<button class='btn btn-danger' type='button' onclick='delProject(\""+row.id+"\")'><i class='glyphicon glyphicon-trash'></i>&nbsp;删除</button>&nbsp;&nbsp;"
                        return buttonText;
                        console.info(data);
                        console.info(row);
                        console.info(index);
                    }
                }],
                url:"/project/getList",
                search:true,

            })
        })

        function openFileMember(projectId){
            var t=layer.open({
                type:2,
                title:"文件管理器",
                shadeClose:true,
                shade:true,
                maxmin:true,
                content:"/filemember/main?projectId="+projectId,
                area:['auto','auto'],
                success:function(layero,index){
                    layer.full(index);
                }
            })
        }
        function createProject(){
            var t=layer.open({
                type:2,
                title:"创建项目",
                shadeClose:false,
                shade:true,
                maxmin:true,
                content:"/project/input",
                area:['300px','300px'],
                success:function(layero,index){

                },
                btn:["创建","关闭"],
                yes: function(index,layero) {
                    var body = layer.getChildFrame('body', index);
                    //得到iframe页的窗口对象
                    var iframeWin = window[layero.find('iframe')[0]['name']];
                    if(iframeWin.save())
                    {
                        $('#dataTable').bootstrapTable("refresh",{
                            silent: true
                        })
                        layer.close(index);
                    }

                }
            })
        }
        function delProject(projectId)
        {
            $.post("/project/delProject",{
                projectId:projectId
            },function(){
                layer.msg("删除成功");
                $('#dataTable').bootstrapTable("refresh",{
                    silent: true
                })
            })
        }

    </script>
</head>
<body>
<div class="btn-toolbar" style="margin:5px">
    <button class="btn btn-primary" onclick="createProject()"><i class="glyphicon glyphicon-plus"></i>&nbsp;新增</button>
    <!--<button class="btn"><i class="glyphicon glyphicon-pencil"></i>编辑</button>
    <button class="btn"><i class="glyphicon glyphicon-minus"></i>删除</button>-->
</div>
<div class="contentTable">
    <!--bootstrapTable组件-->
    <table id="dataTable"></table>
</div>

</body>
</html>